package com.zl.autocode.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zl.autocode.controller.base.AutocodeBaseController;
import com.zl.autocode.dto.autocode.fieldMapping.ReqFieldMappingAddDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ReqFieldMappingDelDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ReqFieldMappingDetailDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ReqFieldMappingEditDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ReqFieldMappingQueryDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ReqFieldMappingStateDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ResFieldMappingAddDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ResFieldMappingDelDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ResFieldMappingDetailDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ResFieldMappingEditDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ResFieldMappingQueryDTO;
import com.zl.autocode.dto.autocode.fieldMapping.ResFieldMappingStateDTO;
import com.zl.autocode.service.autocode.IFieldMappingService;
import com.zl.common.dto.ReqDTO;
import com.zl.common.dto.ResDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 字段映射
 * @author ZL
 */
@Api(value="字段映射",tags ="字段映射")
@RestController("autocodeFieldMappingController")
@RequestMapping("/autocode/fieldMapping")
public class FieldMappingController extends AutocodeBaseController {

    @Autowired
    private IFieldMappingService fieldMappingService;
    
    /**
     * 查询
     */
    @ApiOperation(value="字段映射-查询")
    @RequestMapping(value="/list", method = RequestMethod.POST)
    public ResDTO<ResFieldMappingQueryDTO> listFieldMapping(@RequestBody ReqDTO<ReqFieldMappingQueryDTO> reqInfo) throws Exception{
        ResFieldMappingQueryDTO data = fieldMappingService.queryFieldMappingList(reqInfo);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="字段映射-详情")
    @RequestMapping(value="/detail", method = RequestMethod.POST)
    public ResDTO<ResFieldMappingDetailDTO> detailFieldMapping(@RequestBody ReqDTO<ReqFieldMappingDetailDTO> reqInfo) throws Exception{
        ResFieldMappingDetailDTO data = fieldMappingService.queryFieldMappingDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="字段映射-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
        public ResDTO<ResFieldMappingAddDTO> addFieldMapping(@RequestBody ReqDTO<ReqFieldMappingAddDTO> reqInfo) throws Exception{
        ResFieldMappingAddDTO data = fieldMappingService.insertFieldMappingInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="字段映射-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
        public ResDTO<ResFieldMappingEditDTO> editFieldMapping(@RequestBody ReqDTO<ReqFieldMappingEditDTO> reqInfo) throws Exception{
        ResFieldMappingEditDTO data = fieldMappingService.updateFieldMappingInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="字段映射-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
        public ResDTO<ResFieldMappingDelDTO> delFieldMapping(@RequestBody ReqDTO<ReqFieldMappingDelDTO> reqInfo) throws Exception{
        ResFieldMappingDelDTO data = fieldMappingService.deleteFieldMappingInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="字段映射-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
        public ResDTO<ResFieldMappingStateDTO> stateFieldMapping(@RequestBody ReqDTO<ReqFieldMappingStateDTO> reqInfo) throws Exception{
        ResFieldMappingStateDTO data = fieldMappingService.updateFieldMappingState(reqInfo);
        return successDATA(data); 
    }
    
    
}